﻿<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="RootMaster.Master" CodeBehind="Maintenance.aspx.cs" ValidateRequest="false" Inherits="IisHost.UI.Maintenance" %>
<%@ Register TagPrefix="ctl" TagName="RuntimeControl" Src="RuntimeControl.ascx" %>
<%@ Register TagPrefix="ctl" TagName="DatabaseControl" Src="DatabaseControl.ascx" %>
<%@ Register TagPrefix="ctl" TagName="PasswordControl" Src="PasswordControl.ascx" %>
<%@ Register TagPrefix="ctl" TagName="LoginControl" Src="LoginControl.ascx" %>
<%@ Register TagPrefix="ctl" TagName="NHibernateControl" Src="NHibernateControl.ascx" %>
<%@ Register TagPrefix="ctl" TagName="PluginControl" Src="PluginControl.ascx" %>
<%@ Register TagPrefix="ctl" TagName="LogControl" Src="LogControl.ascx" %>

<asp:Content runat="server" ContentPlaceHolderID="cphPageContent">
    <header>
        <ul class="toolbar">
            <li><asp:Button runat="server" ID="btnLogout" OnCommand="OnCommand" CommandName="Logout" Text="Logout" ValidationGroup="Logout" /></li>
        </ul>
        <h1>Xenta Framework Maintenance Panel</h1>
    </header>
    <section runat="server" ID="pnlContent">
        <ctl:PasswordControl runat="server" ID="ctlPassword" />
        <ctl:RuntimeControl runat="server" ID="ctlRuntime" />
        <ctl:DatabaseControl runat="server" ID="ctlDatabase" />
        <section class="block">
            <header>
                <h2>Infrastructure Manager</h2>
            </header>
            <section>
                <div class="tabContainer" id="tabInfrastructures">
                    <div class="tabHeaders">
                        <ul>
                            <li id="tabHeader_0">
                                <span>*</span>
                            </li>
                            <asp:Repeater runat="server" ID="lstInfrastructures1">
                                <ItemTemplate>
                                    <li id="tabHeader_<%#(Container.ItemIndex + 1)%>">
                                        <span><%#(Container.DataItem)%></span>
                                        &nbsp;
                                        <asp:LinkButton runat="server" 
                                            ID="btnDelete" 
                                            CssClass="confirm"
                                            OnCommand="OnCommand" 
                                            CommandName="InfrastructureDelete" 
                                            CommandArgument="<%#(Container.DataItem)%>" 
                                            Text="[x]" 
                                            ValidationGroup="InfrastructureDelete" />
                                    </li>
                                </ItemTemplate>
                            </asp:Repeater>
                        </ul>
                    </div>
                    <div class="tabPages">
                        <div class="tabPage" id="tabPage_0">
                            <table class="form">
                                <tr>
                                    <td>
                                        <label>Name</label>
                                    </td>
                                    <td>
                                        <asp:TextBox runat="server" ID="txtInfrastructure_Name" ValidationGroup="InfrastructureCreate" />
                                    </td>
                                </tr>
                                <tr>
                                    <td></td>
                                    <td>
                                       <asp:Button runat="server" ID="btnSave" OnCommand="OnCommand" CommandName="InfrastructureCreate" Text="Create" ValidationGroup="InfrastructureCreate" /> 
                                    </td>
                                </tr>
                            </table>
                        </div>
                        <asp:Repeater runat="server" ID="lstInfrastructures2" OnItemDataBound="lstInfrastructures2_OnItemDataBound">
                            <ItemTemplate>
                                <div class="tabPage" id="tabPage_<%#(Container.ItemIndex + 1)%>">
                                    <ctl:NHibernateControl runat="server" ID="ctlNHibernate" />
                                    <ctl:PluginControl runat="server" ID="ctlPlugins" />
                                </div>
                            </ItemTemplate>
                        </asp:Repeater>
                    </div>
                </div>
            </section>
            <script type="text/javascript">
                var container = document.getElementById('tabInfrastructures');
                var navItems = container.querySelector('.tabHeaders ul li');
                var ident = navItems.id.split('_')[1];
                var tabPages = container.querySelectorAll('.tabPage');
                var tabHeaders = container.querySelectorAll('.tabHeaders ul li');
                navItems.parentNode.setAttribute('data-current', ident);
                navItems.setAttribute('class', 'tabActiveHeader');
                for (var i = 1; i < tabPages.length; i++)
                    tabPages[i].style.display = 'none';
                for (var i = 0; i < tabHeaders.length; i++) {
                    tabHeaders[i].onclick = function () {
                        var current = this.parentNode.getAttribute('data-current');
                        var ident2 = this.id.split("_")[1];
                        document.getElementById('tabHeader_' + current).removeAttribute('class');
                        document.getElementById('tabPage_' + current).style.display = 'none';
                        this.setAttribute('class', 'tabActiveHeader');
                        document.getElementById('tabPage_' + ident2).style.display = 'block';
                        this.parentNode.setAttribute('data-current', ident2);
                    };
                }
            </script>
            <ctl:LogControl runat="server" ID="ctlLog" Log="log.txt" />
        </section>
    </section>
    <section runat="server" ID="pnlLogin">
        <ctl:LoginControl runat="server" ID="ctlLogin" />
    </section>
</asp:Content>